package com.myh.gulimall.search.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description: // 类说明，在创建类时要填写
 * @ClassName: GulimallElasticSearchConfig    // 类名，会自动填充
 * @Author: MYH          // 创建者
 * @Date: 2024/2/22 18:50   // 时间
 * @Version: 1.0     // 版本
 */
@Configuration
public class GulimallElasticSearchConfig {

    //配置es的请求设置项。
    public static final RequestOptions COMMON_OPTIONS;
    static {
        RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
        COMMON_OPTIONS = builder.build();
    }
    @Bean
    public RestHighLevelClient restHighLevelClient(){
        RestHighLevelClient restHighLevelClient = new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost("192.168.137.10", 9200, "http")
                )
        );
        return restHighLevelClient;
    }

}
